package com.szsanshan.station.datacollector.mapper;


import com.szsanshan.station.datacollector.entity.Fuelpos;
import com.szsanshan.station.datacollector.entity.StationNozzleRecord;
import com.szsanshan.station.datacollector.entity.StationNozzleStatus;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface FuelposMapper {

    @Update("update Fuel_Pay set paystate = 101 WHERE Fuel_payID = #{id}")
    void update(String id);

    @Select("SELECT Fuel_payID as id,nozzleno,oilsort,qty,actualprice,actualmoney,recetime,worktime,totalaccuv as noztotalend,a.Employee as jiayouyuan" +
            " FROM Fuel_Pay t left join Employee a on t.IC_CardID = a.EmployeeID where paystate!=101")
    List<Fuelpos> findAll();

    //    SELECT NozzleNO,Money,OnlineStatus case 2 在线 else 脱机,GunStatus case GunOn 提枪 case GunOff 挂枪,
    //    MotorStatus case 1正在加油 case 0 停止加油,Preset 当GunOn 时如果不为零,为定量加油
    @Select("SELECT NozzleNO as gunno,case gunstatus when 'GunOn' then '1' else '0' end as istake,Money as curramount,Qty as currnum FROM Fuel_Status")
    List<StationNozzleStatus> getNozzleStatus();

    @Select("SELECT id,gunNo as nozno,gasAmount as nozqty,salePrice as nozprice,gsPrice as nozmny,finishTime as endtime "
            + "FROM transaction_record t" + " where id>#{min} and id <#{max} order by id desc")
    List<StationNozzleRecord> findRedisTrade(@Param("min") Long min, @Param("max") Long max);
}
